<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: Kernel</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">Kernel</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing_rb.html">
                vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb
                </a>
        <br />
                <a href="../files/vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger_rb.html">
                vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb
                </a>
        <br />
                <a href="../files/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting_rb.html">
                vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb
                </a>
        <br />
                <a href="../files/vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires_rb.html">
                vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires.rb
                </a>
        <br />
                <a href="../files/vendor/rails/activesupport/lib/active_support/vendor/builder-2_1_2/blankslate_rb.html">
                vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/blankslate.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Since Ruby is very dynamic, methods added to the ancestors of <a
href="BlankSlate.html">BlankSlate</a> <em>after <a
href="BlankSlate.html">BlankSlate</a> is defined</em> will show up in the
list of available <a href="BlankSlate.html">BlankSlate</a> methods. We
handle this by defining a hook in the <a href="Object.html">Object</a> and
<a href="Kernel.html">Kernel</a> classes that will hide any method defined
after <a href="BlankSlate.html">BlankSlate</a> has been loaded.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001638">breakpoint</a>&nbsp;&nbsp;
      <a href="#M001636">daemonize</a>&nbsp;&nbsp;
      <a href="#M001637">debugger</a>&nbsp;&nbsp;
      <a href="#M001640">enable_warnings</a>&nbsp;&nbsp;
      <a href="#M001644">method_added</a>&nbsp;&nbsp;
      <a href="#M001643">require_library_or_gem</a>&nbsp;&nbsp;
      <a href="#M001641">silence_stream</a>&nbsp;&nbsp;
      <a href="#M001639">silence_warnings</a>&nbsp;&nbsp;
      <a href="#M001642">suppress</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">



    <div id="aliases-list">
      <h3 class="section-bar">External Aliases</h3>

      <div class="name-list">
                        <table summary="aliases">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">method_added</td>
          <td>-&gt;</td>
          <td class="context-item-value">blank_slate_method_added</td>
        </tr>
                        </table>
      </div>
    </div>


      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M001644" class="method-detail">
        <a name="M001644"></a>

        <div class="method-heading">
          <a href="#M001644" class="method-signature">
          <span class="method-name">method_added</span><span class="method-args">(name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Detect method additions to <a href="Kernel.html">Kernel</a> and remove them
in the <a href="BlankSlate.html">BlankSlate</a> class.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001644-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001644-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/blankslate.rb, line 65</span>
65:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_added</span>(<span class="ruby-identifier">name</span>)
66:       <span class="ruby-identifier">result</span> = <span class="ruby-identifier">blank_slate_method_added</span>(<span class="ruby-identifier">name</span>)
67:       <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">Kernel</span>
68:       <span class="ruby-constant">BlankSlate</span>.<span class="ruby-identifier">hide</span>(<span class="ruby-identifier">name</span>)
69:       <span class="ruby-identifier">result</span>
70:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M001638" class="method-detail">
        <a name="M001638"></a>

        <div class="method-heading">
          <a href="#M001638" class="method-signature">
          <span class="method-name">breakpoint</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001638-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001638-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb, line 9</span>
 9:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">breakpoint</span>
10:     <span class="ruby-constant">RAILS_DEFAULT_LOGGER</span>.<span class="ruby-identifier">info</span> <span class="ruby-value str">&quot;\n***** The 'breakpoint' command has been renamed 'debugger' -- please change *****\n&quot;</span>
11:     <span class="ruby-identifier">debugger</span>
12:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001636" class="method-detail">
        <a name="M001636"></a>

        <div class="method-heading">
          <a href="#M001636" class="method-signature">
          <span class="method-name">daemonize</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Turns the current script into a daemon process that detaches from the
console. It can be shut down with a TERM signal.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001636-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001636-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb, line 4</span>
 4:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">daemonize</span>
 5:     <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>                   <span class="ruby-comment cmt"># Parent exits, child continues.</span>
 6:     <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>                 <span class="ruby-comment cmt"># Become session leader.</span>
 7:     <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>                   <span class="ruby-comment cmt"># Zap session leader. See [1].</span>
 8:     <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span> <span class="ruby-value str">&quot;/&quot;</span>                  <span class="ruby-comment cmt"># Release old working directory.</span>
 9:     <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>                <span class="ruby-comment cmt"># Ensure sensible umask. Adjust as needed.</span>
10:     <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>       <span class="ruby-comment cmt"># Free file descriptors and</span>
11:     <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>, <span class="ruby-value str">&quot;a&quot;</span> <span class="ruby-comment cmt"># point them somewhere sensible.</span>
12:     <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-constant">STDOUT</span>           <span class="ruby-comment cmt"># STDOUT/ERR should better go to a logfile.</span>
13:     <span class="ruby-identifier">trap</span>(<span class="ruby-value str">&quot;TERM&quot;</span>) { <span class="ruby-identifier">exit</span> }
14:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001637" class="method-detail">
        <a name="M001637"></a>

        <div class="method-heading">
          <a href="#M001637" class="method-signature">
          <span class="method-name">debugger</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Starts a debugging session if ruby-debug has been loaded (call
script/server &#8212;<a href="Kernel.html#M001637">debugger</a> to do load
it).
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001637-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001637-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb, line 4</span>
4:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debugger</span>
5:       <span class="ruby-constant">RAILS_DEFAULT_LOGGER</span>.<span class="ruby-identifier">info</span> <span class="ruby-value str">&quot;\n***** Debugger requested, but was not available: Start server with --debugger to enable *****\n&quot;</span>
6:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001640" class="method-detail">
        <a name="M001640"></a>

        <div class="method-heading">
          <a href="#M001640" class="method-signature">
          <span class="method-name">enable_warnings</span><span class="method-args">() {|| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Sets $VERBOSE to true for the duration of the block and back to its
original value afterwards.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001640-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001640-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb, line 17</span>
17:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">enable_warnings</span>
18:     <span class="ruby-identifier">old_verbose</span>, <span class="ruby-identifier">$VERBOSE</span> = <span class="ruby-identifier">$VERBOSE</span>, <span class="ruby-keyword kw">true</span>
19:     <span class="ruby-keyword kw">yield</span>
20:   <span class="ruby-keyword kw">ensure</span>
21:     <span class="ruby-identifier">$VERBOSE</span> = <span class="ruby-identifier">old_verbose</span>
22:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001643" class="method-detail">
        <a name="M001643"></a>

        <div class="method-heading">
          <a href="#M001643" class="method-signature">
          <span class="method-name">require_library_or_gem</span><span class="method-args">(library_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Require a library with fallback to RubyGems. Warnings during library
loading are silenced to increase signal/noise for application warnings.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001643-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001643-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires.rb, line 4</span>
 4:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">require_library_or_gem</span>(<span class="ruby-identifier">library_name</span>)
 5:     <span class="ruby-identifier">silence_warnings</span> <span class="ruby-keyword kw">do</span>
 6:       <span class="ruby-keyword kw">begin</span>
 7:         <span class="ruby-identifier">require</span> <span class="ruby-identifier">library_name</span>
 8:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">cannot_require</span>
 9:         <span class="ruby-comment cmt"># 1. Requiring the module is unsuccessful, maybe it's a gem and nobody required rubygems yet. Try.</span>
10:         <span class="ruby-keyword kw">begin</span>
11:           <span class="ruby-identifier">require</span> <span class="ruby-value str">'rubygems'</span>
12:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">rubygems_not_installed</span>
13:           <span class="ruby-identifier">raise</span> <span class="ruby-identifier">cannot_require</span>
14:         <span class="ruby-keyword kw">end</span>
15:         <span class="ruby-comment cmt"># 2. Rubygems is installed and loaded. Try to load the library again</span>
16:         <span class="ruby-keyword kw">begin</span>
17:           <span class="ruby-identifier">require</span> <span class="ruby-identifier">library_name</span>
18:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">gem_not_installed</span>
19:           <span class="ruby-identifier">raise</span> <span class="ruby-identifier">cannot_require</span>
20:         <span class="ruby-keyword kw">end</span>
21:       <span class="ruby-keyword kw">end</span>
22:     <span class="ruby-keyword kw">end</span>
23:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001641" class="method-detail">
        <a name="M001641"></a>

        <div class="method-heading">
          <a href="#M001641" class="method-signature">
          <span class="method-name">silence_stream</span><span class="method-args">(stream) {|| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Silences any stream for the duration of the block.
</p>
<pre>
  silence_stream(STDOUT) do
    puts 'This will never be seen'
  end

  puts 'But this will'
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001641-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001641-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb, line 36</span>
36:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">silence_stream</span>(<span class="ruby-identifier">stream</span>)
37:     <span class="ruby-identifier">old_stream</span> = <span class="ruby-identifier">stream</span>.<span class="ruby-identifier">dup</span>
38:     <span class="ruby-identifier">stream</span>.<span class="ruby-identifier">reopen</span>(<span class="ruby-constant">RUBY_PLATFORM</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/mswin/</span> <span class="ruby-operator">?</span> <span class="ruby-value str">'NUL:'</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'/dev/null'</span>)
39:     <span class="ruby-identifier">stream</span>.<span class="ruby-identifier">sync</span> = <span class="ruby-keyword kw">true</span>
40:     <span class="ruby-keyword kw">yield</span>
41:   <span class="ruby-keyword kw">ensure</span>
42:     <span class="ruby-identifier">stream</span>.<span class="ruby-identifier">reopen</span>(<span class="ruby-identifier">old_stream</span>)
43:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001639" class="method-detail">
        <a name="M001639"></a>

        <div class="method-heading">
          <a href="#M001639" class="method-signature">
          <span class="method-name">silence_warnings</span><span class="method-args">() {|| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Sets $VERBOSE to nil for the duration of the block and back to its original
value afterwards.
</p>
<pre>
  silence_warnings do
    value = noisy_call # no warning voiced
  end

  noisy_call # warning voiced
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001639-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001639-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb, line 9</span>
 9:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">silence_warnings</span>
10:     <span class="ruby-identifier">old_verbose</span>, <span class="ruby-identifier">$VERBOSE</span> = <span class="ruby-identifier">$VERBOSE</span>, <span class="ruby-keyword kw">nil</span>
11:     <span class="ruby-keyword kw">yield</span>
12:   <span class="ruby-keyword kw">ensure</span>
13:     <span class="ruby-identifier">$VERBOSE</span> = <span class="ruby-identifier">old_verbose</span>
14:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001642" class="method-detail">
        <a name="M001642"></a>

        <div class="method-heading">
          <a href="#M001642" class="method-signature">
          <span class="method-name">suppress</span><span class="method-args">(*exception_classes) {|| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001642-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001642-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb, line 45</span>
45:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">suppress</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">exception_classes</span>)
46:     <span class="ruby-keyword kw">begin</span> <span class="ruby-keyword kw">yield</span>
47:     <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
48:       <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">exception_classes</span>.<span class="ruby-identifier">any?</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">cls</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-identifier">cls</span>) }
49:     <span class="ruby-keyword kw">end</span>
50:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>